﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ShardMath
{
    class stackObject
    {
        private object[] itemStack;
        private int maxSize;
        //-1 represents no stack items
        private int stackPointer = -1;

        public stackObject(int stackSize)
        {
            itemStack = new object[stackSize];
            maxSize = stackSize;
        }

        public object pop()
        {
            if (stackPointer > -1)
            {
                object outputItem = itemStack[stackPointer];
                stackPointer = stackPointer - 1;
                return outputItem;
            }
            return 0;
        }

        public object peep()
        {
            if (stackPointer > -1)
            {
                return itemStack[stackPointer];
            }
            return 0;
        }

        public bool push(int newItem)
        {
            if (stackPointer < maxSize)
            {
                stackPointer = stackPointer + 1;
                itemStack[stackPointer] = newItem;
                return true;
            }
            return false;
        }
    }
}
